package conf2.ui;

import conf2.model.EActor.Side;
import java.awt.Frame;
import java.awt.Image;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.JDialog;
import javax.swing.JPanel;

public class ActorInfoDialog extends JDialog {

    public ActorInfoDialog(Frame parent, String name, String desc, int atkVal, Image img, Side side) {
        super(parent, true);

        setUndecorated(true);

        JPanel p = new ActorInfoPanel(name, desc, atkVal, img, side);
        add(p);

        p.addMouseListener(new MouseAdapter() {

            @Override
            public void mousePressed(MouseEvent e) {
                e.consume();
                dispose();
            }
        });

        addKeyListener(new KeyAdapter() {

            @Override
            public void keyPressed(KeyEvent e) {
                if (e.getKeyCode() == KeyEvent.VK_ENTER ||
                        e.getKeyCode() == KeyEvent.VK_ESCAPE ||
                        e.getKeyCode() == KeyEvent.VK_SPACE) {
                    e.consume();
                    dispose();
                }
            }
        });

        pack();
        setLocationRelativeTo(parent);
    }

}
